<?php
namespace Admin\Controller;
use Common\Controller\AdminbaseController;
class ZhuhuController extends AdminbaseController{
    
    protected $menu_model;

    function _initialize() {
        parent::_initialize();
        $this->menu_model = M("zhuhu");

    }

    public function zhuhuadd(){

        $this->display();

    }

    public function zhuhulist(){

        $info=$this->menu_model->select();

        $this->assign('info', $info);

            $this->display();

    }

    public function zhuhudel(){

            $this->display();

    }

    public function add_post() {
    	if (IS_POST) {
    		if ($this->menu_model->create()) {
    			if ($this->menu_model->add()!==false) {
                         
                            $ar=array(
    				'name'=>$_POST['name'],
                                'xiaoqu'=>$_POST['xiaoqu'],
                                'louyu'=>$_POST['louyu'],
                                'danyuan'=>$_POST['danyuan'],
                                'fanghao'=>$_POST['fanghao'],
                                'xingbie'=>$_POST['xingbie'],
                                'zhphone'=>$_POST['zhphone'],
                                'zhshenfen'=>$_POST['zhshenfen'],
                                'jtphone'=>$_POST['jtphone'],
                                'qianrutime'=>$_POST['qianrutime'],
                                'qianruyuanyin'=>$_POST['qianruyuanyin']
                                );
                               $this->menu_model->add();
    				 $this->success("添加成功！");
    			} else {
    				$this->error("添加失败！");
    			}
    		} else {
    			$this->error($this->menu_model->getError());
    		}
               
    	}
    }
    
    
    function delete(){
        $id = intval(I("get.id")); 
          $count = $this->menu_model->where(array("parentid" => $id))->count();
    
        if ($this->menu_model->delete($id)!==false) {
            $this->success("删除成功！");
        } else {
            $this->error("删除失败！");
        }
        
        
    }
    
    function zhuhuupdata(){
 
        $id = intval(I("get.id"));
        $res=$this->menu_model->where('id=%d',array($id))->select();
        $this->assign('res', $res);
        $this->display(); 
        
        
    }
    function save(){

       	if (IS_POST) {
    		if ($this->menu_model->create()) {
    			if ($this->menu_model->save()!==false) {
                            $ar=array(
    				'name'=>$_POST['name'],
                                'xiaoqu'=>$_POST['xiaoqu'],
                                'louyu'=>$_POST['louyu'],
                                'danyuan'=>$_POST['danyuan'],
                                'fanghao'=>$_POST['fanghao'],
                                'xingbie'=>$_POST['xingbie'],
                                'zhphone'=>$_POST['zhphone'],
                                'zhshenfen'=>$_POST['zhshenfen'],
                                'jtphone'=>$_POST['jtphone'],
                                'qianrutime'=>$_POST['qianrutime'],
                                'qianruyuanyin'=>$_POST['qianruyuanyin']
                                );
                               $this->menu_model->where('id=%d',array($_POST['id']))->save();
    				 $this->success("更新成功！");
    			} else {
    				$this->error("更新失败！");
    			}
    		} else {
    			$this->error($this->menu_model->getError());
    		}
               
    	}
        
    }
    
}